#ifndef CGPS_H
#define CGPS_H

#include <QObject>
#include <QGeoSatelliteInfoSource>
#include <QGeoPositionInfoSource>


// Use the QtMobility namespace
QTM_USE_NAMESPACE

class CGps : public QObject
{
    Q_OBJECT

public:
    CGps(QObject *parent = 0);
    virtual ~CGps();

signals:
    // this signal will be sent when we have got a
    // new position from the GPS system
    void positionUpdatedAlready(qreal lat, qreal lon);

protected Q_SLOTS:
    virtual void positionUpdated(const QGeoPositionInfo &gpsPos);

protected Q_SLOTS:
    // this slot will be invoked when the time out error occures the first time
    virtual void updateTimeout() = 0;
    // this slot will be invoked when the statistics have been received and we can do the work now
    virtual void work() = 0;

public:
    bool initialize();
    void setUpdateInterval(int milliseconds = 20000 );
    void startUpdate();
    void stopUpdate();

    // this function is called when we want to update the position
    // even when the interval doesnot arrive
    void requestUpdate();


protected:
    QGeoPositionInfoSource  *m_pLocation;
    qreal                    m_latitude;
    qreal                    m_longitude;
};

#endif // CGPS_H
